programming4us
           
 
 
Programming

Programming Windows Azure : Table Operations - Deleting Tables, Deleting Entities

- Free product key for windows 10
- Free Product Key for Microsoft office 365
- Malwarebytes Premium 3.7.1 Serial Keys (LifeTime) 2019
11/21/2010 11:39:13 AM

1. Deleting Tables

Deleting tables is extremely easy. A simple call to CloudTableClient.DeleteTable will obliterate all your tables. Note that deleting large tables can take some time. If you try to re-create a table quickly after it is deleted, you could get an error message.

Example 1 shows the code for deleting the ContactsTable. Once you delete a table, it is immediately inaccessible for operations. Unlike other distributed storage services, there is no propagation delay that lets other operations succeed.

Example 1. Deleting the table
account.CreateCloudTableClient().DeleteTable("ContactsTable");

The REST equivalent is just as simple. Just send an HTTP DELETE to the table’s URL and you’re done.

DELETE /Tables('ContactTable') HTTP/1.1
User-Agent: Microsoft ADO.NET Data Services
x-ms-date: Mon, 20 Apr 2009 18:34:37 GMT
Authorization: SharedKeyLite sriramk:vhJAA1od931iUvj8MEBu4pb1hu3fIILiA15Ndf3n+8Y=

2. Deleting Entities

Deleting entities is similar to deleting tables. You retrieve the entity you want to delete through a query, call DataServiceContext.DeleteObject, and save changes back. Example 2 shows the code to do this.

Example 2. Deleting entities
CloudStorageAccount.Parse(ConfigurationSettings.AppSettings
["DataConnectionString"]);
var svc = new TestDataServiceContext(account.TableEndpoint.ToString(),
account.Credentials);
var item = (from contact in svc.CreateQuery<Contact>("ContactTable")
where contact.Name == "Steve Jobs"
select contact).Single();
svc.DeleteObject(item);
svc.SaveChanges();


However, this means you can delete entities only when you’ve already queried and retrieved them from table storage. This is inefficient when deleting large sets of entities, and it seems counterintuitive to query entities just to delete them. You can work around this by creating a dummy local entity with the right partition key and row key, attaching it to the DataServiceContext, and then deleting it.

Example 3 shows how to do this. This mandates that you already know the partition key and row key for the item you want to delete. In Example 3, you would replace CorrectPartitionKey and CorrectRowKey with the actual partition key and row key, respectively.

Example 3. Deleting entities without querying
            var svc =
new TestDataServiceContext(account.TableEndpoint.ToString(),
account.Credentials);
var item = new Contact("CorrectPartitionKey", "CorrectRowKey");
svc.AttachTo("ContactTable", item, "*");
svc.DeleteObject(item);
svc.SaveChanges();

How does this work? Note the wildcard character passed as a parameter to the AttachTo method. Here, you’re bringing an empty object into the DataServiceContext’s view of the local world, deleting it, and then using the wildcard to say that “regardless of what changes have happened on the server, replace with changes with this version.” Since the only change here is to delete the object, the deletion is propagated to the server.

If you inspect the HTTP traffic, you’ll notice one key difference between normal deletes and this variant. Normally, the delete operation specifies an ETag to say, “I’m trying to perform an operation on this version of the object.” In this variant, you see the header If-Match: *, which essentially says, “Perform this operation on any version of the object.”

There are trade-offs when picking either of these variants. Pick the former when you want to delete a specific version of your entity and you don’t care about any intermediate updates. Use the latter version when you want to obliterate the entity, no matter what has happened since you last retrieved it.

Other -----------------
- Programming Windows Azure : Table Operations - Updating Entities
- Programming Windows Azure : Table Operations - Understanding Pagination
- Programming Windows Azure : Table Operations - Using Partitioning
- Programming Windows Azure : Table Operations - Querying Data
- Programming Windows Azure : Table Operations - Creating Entities
- Programming Windows Azure : Table Operations - Creating Tables
- iPad Development : Document Management (part 2)
- iPad Development : Document Management (part 1)
- iPad Development : The Split View Concept
- jQuery 1.3 : Developing plugins - Adding new shortcut methods
- jQuery 1.3 : Developing plugins - DOM traversal methods
- Using Cloud Services : Exploring Online Planning and Task Management
- Using Cloud Services : Exploring Online Scheduling Applications
- Using Cloud Services : Exploring Online Calendar Applications
- SOA with .NET and Windows Azure : Service Contracts with WCF (part 3)
- SOA with .NET and Windows Azure : Service Contracts with WCF (part 2)
- SOA with .NET and Windows Azure : Service Contracts with WCF (part 1)
- Cloud Security and Privacy : Data Security and Storage
- iPad SDK : Working with Documents - Desktop Synchronization
- Required Project Images for iPad Apps
 
 
 
Top 10
 
- Microsoft Visio 2013 : Adding Structure to Your Diagrams - Finding containers and lists in Visio (part 2) - Wireframes,Legends
- Microsoft Visio 2013 : Adding Structure to Your Diagrams - Finding containers and lists in Visio (part 1) - Swimlanes
- Microsoft Visio 2013 : Adding Structure to Your Diagrams - Formatting and sizing lists
- Microsoft Visio 2013 : Adding Structure to Your Diagrams - Adding shapes to lists
- Microsoft Visio 2013 : Adding Structure to Your Diagrams - Sizing containers
- Microsoft Access 2010 : Control Properties and Why to Use Them (part 3) - The Other Properties of a Control
- Microsoft Access 2010 : Control Properties and Why to Use Them (part 2) - The Data Properties of a Control
- Microsoft Access 2010 : Control Properties and Why to Use Them (part 1) - The Format Properties of a Control
- Microsoft Access 2010 : Form Properties and Why Should You Use Them - Working with the Properties Window
- Microsoft Visio 2013 : Using the Organization Chart Wizard with new data
- First look: Apple Watch

- 3 Tips for Maintaining Your Cell Phone Battery (part 1)

- 3 Tips for Maintaining Your Cell Phone Battery (part 2)
programming4us programming4us